<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
		$('#chrcount').keyup(function(){
			var len = $('#chrcount').val();
			var char = len.length;	
			if(254-char == 0){
				}
			$('#chrcountlength').html(255-char);	
		});
	});
	
	$(document).ready(function(){
		$('#chrcount2').keyup(function(){
			var len = $('#chrcount2').val();
			var char = len.length;	
			if(254-char == 0){
				}
			$('#chrcountlength2').html(255-char);	
		});
	});
</script>

<div id="mws-container" class="clearfix">
<div class="container">
  <div class="mws-panel grid_8">
    <div class="mws-panel-header"> <span class="mws-i-24 i-list"><?php if(isset($details['AttrGroup']['id']) and ($details['AttrGroup']['id'])){ echo "Edit"; }else {?>Add <?php } ?> Attribute Group</span> </div>
    <div class="mws-panel-body">
      <div class="mws-form-inline"> 
	  <?php echo $form->create(array('controller'=>'setups','action'=>'','method'=>'post','class' => 'mws-form')); ?>
      <?php 
			if(isset($details['AttrGroup']['id'])){$details['AttrGroup']['id']=$details['AttrGroup']['id'];}else{$details['AttrGroup']['id']="";}
			echo $this->Form->input('AttrGroup.id', array('type' => 'hidden','value'=>$details['AttrGroup']['id']));?>
        <div class="mws-form-row">
          <label>* Title :</label>
          <div class="mws-form-item small"> 
		  <?php
	if(isset($details['AttrGroup']['name'])){$details['AttrGroup']['name']=$details['AttrGroup']['name'];}else{$details['AttrGroup']['name']="";}
		 echo $this->Form->input('AttrGroup.name', 
				  array('type' => 'text','value'=>$details['AttrGroup']['name'],
				  'class'=>'mws-textinput','label' =>false
				  ));?> </div>
        </div>
        
        <div class="mws-form-row">
          <label>* Category :</label>
          <div class="mws-form-item small"> 
            <select id="ProductCatId" class="mws-textinput" name="data[AttrGroup][cat_id]">
            <?php
            foreach ($_list_categories as $_list_category)
                {
                if (isset($_list_category['subcatecategories']) and ($_list_category['subcatecategories']))
                    {
                    if ($_list_category['name']):
                        echo "<optgroup label=" . str_replace(" ","_",(str_replace(",","",(str_replace("&","",$_list_category['name']) )))). ">";
                        foreach ($_list_category['subcatecategories'] as $_list_category_sub)
                            {
								if( $_list_category_sub['Category']['id']==$details['AttrGroup']['cat_id'])
								{
									$selected ='selected="selected"';
								}
								else
								{
									$selected = '';
								}
                            echo "<option ".$selected." value=" . $_list_category_sub['Category']['id'] . ">" . $_list_category_sub['Category']['name'] . "</option>";
                            }
                        echo "</optgroup>";
                    endif;
                    }
                }
            ?>
            </select>
                  
                   </div>
        </div>
        
        

        <div class="mws-form-row">
          <label>Sort Type :</label>
          <div class="mws-form-item 	small"> <?php 
if(isset($details['AttrGroup']['sort'])){$details['AttrGroup']['sort']=$details['AttrGroup']['sort'];}else{$details['AttrGroup']['sort']="";}
echo $this->Form->input('AttrGroup.sort', array('type' => 'text','value'=>$details['AttrGroup']['sort'],'class'=>'mws-textinput','label' =>false));?> </div>
        </div>
        <div class="mws-form-row">
          <label>Status Type :</label>
          <div class="mws-form-item 	small">
            <?php 
			
	if(isset($details['AttrGroup']['status'])){$details['AttrGroup']['status']=$details['AttrGroup']['status'];}else{$details['AttrGroup']['status']="";}

				$options = array('1'=>'Active', '0'=>'Deactive'); 
					echo $this->Form->input('AttrGroup.status', 
					array('type' => 'select','options'=>$options,
					'default'=>$details['AttrGroup']['status'],'class'=>'mws-textinput','empty'=>false,'label' =>false)
				);
									?>
          </div>
        </div>
        <div class="mws-form-row">
          <label>
          <p id="chrcountlength2"></p>
          </label>
        </div>
        <div class="mws-button-row">
          <input type="submit" class="mws-button black" value="Submit">
        </div>
        </form>
      </div>
    </div>
  </div>
</div>
s